home *** CD-ROM | disk | other *** search
/ SGI Hot Mix 8 / Hot Mix 8.iso / .all / demos / Z-Mail / InstallIt2 (.txt) < prev    next >
Text File  |  1994-06-22  |  10KB  |  362 lines

  1. #!/bin/csh -f
  2.  
  3. #
  4. # CD_PATH should be set in the environment by InstallIt.  Failsafe it.
  5. #
  6.  
  7. if ( ! $?CD_PATH ) then
  8.     set CD_PATH=`find $HOTMIXDIR/demos -type d -name Z-Mail -print -prune`
  9. endif
  10.  
  11. #
  12. # Test to see if we're IRIX4 or IRIX5
  13. #
  14.  
  15. switch ( `uname -r` )
  16. case 5* :
  17.     set INST_DIR=zmail.sgi5
  18.     set KBYTES_REQ=5581
  19.     breaksw
  20. default :
  21.     set INST_DIR=zmail.sgi
  22.     set KBYTES_REQ=10506
  23.     breaksw
  24. endsw
  25.  
  26. set MYAPP=zmail
  27. set CD_PATH=$CD_PATH/$INST_DIR
  28.  
  29. #
  30. #  Test to see if on the new Indy filesystem or old one.
  31. #
  32.  
  33. set TEST_NEW=`df -k /usr | /usr/bin/awk '{print $7}'`
  34.  
  35. if ( "$TEST_NEW" == "Mounted /" ) then
  36.    set FILE_STRUCTURE=new
  37. else
  38.    set FILE_STRUCTURE=old
  39. endif
  40.  
  41. #
  42. #  Determine the INST_PATH name.
  43. #
  44. #  First try /usr/tmp;  then if necessary, ask for another directory.
  45. #
  46.     
  47. if ( $KBYTES_REQ < 1000 ) then
  48.     set MBYTES_REQ=1
  49. else
  50.     @ MBYTES_REQ = ($KBYTES_REQ) / 1000
  51. endif
  52.  
  53. if ( $FILE_STRUCTURE == "new" ) then
  54.    set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
  55. else
  56.    set KBYTES_AVAIL=`df -k /usr | /bin/grep /usr | /usr/bin/awk '{print $5}'`
  57. endif
  58.  
  59. if ( -w /usr/tmp ) then
  60.  
  61.     if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
  62.  
  63.         set INST_PATH=/usr/tmp/$INST_DIR
  64.  
  65.         echo " "
  66.         echo "This demo requires $MBYTES_REQ Mbytes of disk space."
  67.         echo " "
  68.         echo "It will be installed in a directory named $INST_PATH"
  69.         echo "Is this OK (y/n)?  \c"
  70.         set ans=($<)
  71.         if ( $ans != 'y' ) then
  72.             echo " "
  73.             echo "Do you want to install in another directory (y/n)?  \c"
  74.             set ans2=($<)
  75.             if ( $ans2 != 'y' ) then
  76.                 echo " "
  77.                 echo "... Bye."
  78.                 sleep 3
  79.                 exit
  80.             else
  81.                 set INST_PATH=none
  82.             endif
  83.         else
  84.             if ( -d $INST_PATH ) then
  85.                 echo " "
  86.                 echo "It seems the demo is already installed.  Continue anyway (y/n)?  \c"
  87.                 set ans3=($<)
  88.                 if ( $ans3 != 'y' ) then
  89.                     echo " "
  90.                     echo "... Bye."
  91.                     sleep 3
  92.                     exit
  93.                 endif
  94.                 rm -rf $INST_PATH
  95.             endif
  96.         endif
  97.     else
  98.         set INST_PATH=none
  99.     endif
  100. else
  101.     set INST_PATH=none
  102. endif
  103.  
  104. if ( $INST_PATH == "none" ) then
  105.  
  106. #   Read name of installation directory.
  107.  
  108.     echo " "
  109.     echo "This demo requires $MBYTES_REQ Mbytes of disk space."
  110.  
  111.     LOOP1:
  112.  
  113.     unset INSTDIR_FILESYS
  114.  
  115.     echo " "
  116.     echo "Enter the full path name of an existing directory"
  117.     echo "in which to copy the software (or enter 'q' to quit):  \c"
  118.     set ans=($<)
  119.  
  120. #   Check validity of the path name.  If it contains only a "/",
  121. #   this will cause a divide by zero, and fail.
  122.     set TEST1=`echo $ans | cut -f2 -d"/"`
  123.     if ( ! $#TEST1 ) then
  124.             echo " "
  125.             echo "You cannot use directory /.  Please try again."
  126.             goto LOOP1
  127.     endif
  128.  
  129.     if ( $ans == 'q' ) then
  130.         echo " "
  131.         echo "... Bye."
  132.         sleep 3
  133.         exit
  134.     else if ( $#ans == 0 ) then
  135.         echo " "
  136.         echo "Input error.  Please try again."
  137.         goto LOOP1
  138.     else
  139.  
  140. #       Check validity of the path name again.  It must begin with "/".
  141.         set TEST2=`echo $ans | cut -f1 -d"/" -s`
  142.         set TEST3=`echo $ans | cut -f2 -d"/" -s`
  143.         if ( ( $#TEST2 ) || ( ! $#TEST3 ) ) then
  144.                 echo " "
  145.                 echo "The pathname must begin with /.  Please try again."
  146.                 goto LOOP1
  147.         endif
  148.  
  149.         if ( -d $ans ) then
  150.  
  151.             echo " "
  152.             echo "A $INST_DIR directory will be created in $ans."
  153.             echo "Is this OK (y/n)?:  \c"
  154.             set ans2=($<)
  155.             if ( $ans2 != 'y' ) goto LOOP1
  156.  
  157. #           Determine the space available for the filesystem
  158. #           containing the requested directory.
  159. #
  160.  
  161. #            Check to see if the directory is actually a link or an
  162. #            nfs mount and do appropriate checks.
  163.  
  164.             if ( -l $ans ) then 
  165.                 cd $ans
  166.                 set CDIR=`pwd`
  167.                 set KBYTES_AVAIL=`df -k $CDIR | /usr/bin/awk '{print $5}'`
  168.             endif
  169.  
  170.             touch $ans/hmtest
  171.             if ( ! -r $ans/hmtest ) then
  172.  
  173.                 echo "Can not write to $ans, please choose another directory."
  174.                 goto LOOP1
  175.             endif
  176.             /bin/rm -f $ans/hmtest
  177.  
  178.                 
  179. #           First, find all the mounted filesystems.
  180.             set FILESYSTEMS=`df -k | awk '{print $7}' | grep /`
  181.  
  182. #           Now, beginning with the full path name of the
  183. #           requested directory, start stripping off the trailing
  184. #           subdirectory names, and compare this to the existing
  185. #           file system names.  If these match exactly, then we've
  186. #           found the right file system.
  187.  
  188.             set TEST4=`echo $ans | cut -f3 -d"/"`
  189.             if ( ! $#TEST4 ) then
  190.                 set PATH=$ans
  191.             else
  192.                 set PATH=`dirname $ans`
  193.             endif
  194.             LOOP2:
  195.                 foreach FILESYSTEM ($FILESYSTEMS)
  196.  
  197. #                   Don't do the test if $FILESYSTEM == "/"
  198.                     set TEST5=`echo $FILESYSTEM | cut -f2 -d"/"`
  199.                     if ( $#TEST5 != 0 ) then
  200.  
  201.                         if ( $PATH == $FILESYSTEM ) then
  202.                             set INSTDIR_FILESYS=$PATH
  203.                         endif
  204.                     endif
  205.                 end
  206.                 set PATH=`dirname $PATH`
  207.  
  208. #           Continue looping until we've stripped the pathname
  209. #           down to only "/", or until we find the file system.
  210.  
  211.             set LOOPTEST=`echo $PATH | cut -f2 -d"/"`
  212.             if (( $#LOOPTEST != 0 ) && ( ! $?INSTDIR_FILESYS )) goto LOOP2
  213.  
  214.             if ( $?INSTDIR_FILESYS ) then
  215.  
  216. #               Determine the available space
  217.  
  218.                 set KBYTES_AVAIL=`df -k $INSTDIR_FILESYS | /bin/grep $INSTDIR_FILESYS | /usr/bin/awk '{print $5}'`
  219.  
  220.             else
  221.                 if ( $FILE_STRUCTURE == "new" ) then
  222.                   set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
  223.                 else
  224.                 echo " "
  225.                 echo "  ERROR:  Can't determine the amount of available disk"
  226.                 echo "          space for the directory you requested."
  227.                 echo " "
  228.                 echo "          Continue anyway (y/n)?  \c"
  229.                 set ans3=($<)
  230.                 if ( $ans3 == 'y' ) then
  231.                     @ KBYTES_AVAIL = ($KBYTES_REQ) + 1
  232.                 else
  233.                     echo " "
  234.                     echo "... Bye."
  235.                     sleep 3
  236.                     exit
  237.                 endif
  238.             endif
  239.        endif
  240.  
  241.             if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
  242.                 if ( -w $ans ) then
  243.  
  244. #                   Success!!!
  245.  
  246.                     set INST_PATH=$ans/$INST_DIR
  247.                     echo " "
  248.                 else
  249.                     echo " "
  250.                     echo "Can't write to directory $ans."
  251.                     echo "Please try again."
  252.                     goto LOOP1
  253.                 endif
  254.             else
  255.                 echo " "
  256.                 echo "Not enough disk space available."
  257.                 echo " "
  258.                 echo "     Required space = $KBYTES_REQ Kbytes"
  259.                 echo "    Available space = $KBYTES_AVAIL Kbytes"
  260.                 echo " "
  261.                 echo "Please try again."
  262.                 goto LOOP1
  263.             endif
  264.         else
  265.             echo " "
  266.             echo "Can't find directory $ans."
  267.             goto LOOP1
  268.         endif
  269.     endif
  270.  
  271.     # Check installation directory.
  272.     if ( -d $INST_PATH ) then
  273.         echo " "
  274.         echo "It seems the demo is already installed.  Continue anyway (y/n)?  \c"
  275.         set ans3=($<)
  276.         if ( $ans3 != 'y' ) then
  277.             echo " "
  278.             echo "... Bye."
  279.             sleep 3
  280.             exit
  281.         endif
  282.  
  283.         rm -rf $INST_PATH
  284.     endif
  285. endif
  286.  
  287. #  Store INST_PATH in a file so it can be communicated to the RemoveIt script.
  288. #
  289. #  First, try to put it in /usr/tmp.  If we can't, then put it in /tmp
  290. #  and in the user's home directory.  If put in /tmp, the file will
  291. #  disappear if the machine is rebooted.  If put in the user's home
  292. #  directory, we won't be able to find it if the user trying to remove
  293. #  the software is not the same as the user who installed it.  Either
  294. #  case isn't very good, but it's the best we can do if we can't write
  295. #  to /usr/tmp.
  296.  
  297. /bin/rm -f /usr/tmp/HOTMIXPATH_$INST_DIR > /dev/null
  298. /bin/rm -f /tmp/HOTMIXPATH_$INST_DIR > /dev/null
  299. /bin/rm -f ~/HOTMIXPATH_$INST_DIR > /dev/null
  300.  
  301. if ( -w /usr/tmp ) then
  302.     echo "setenv INST_PATH $INST_PATH" > /usr/tmp/HOTMIXPATH_$INST_DIR
  303.     /bin/chmod 666 /usr/tmp/HOTMIXPATH_$INST_DIR
  304. else
  305.     echo "setenv INST_PATH $INST_PATH" > /tmp/HOTMIXPATH_$INST_DIR
  306.     /bin/chmod 666 /tmp/HOTMIXPATH_$INST_DIR
  307.  
  308.     echo "setenv INST_PATH $INST_PATH" > ~/HOTMIXPATH_$INST_DIR
  309.     /bin/chmod 666 ~/HOTMIXPATH_$INST_DIR
  310. endif
  311.  
  312. #
  313. #-----------------------------------------------------------------------
  314. #
  315. #  Now that we've finally determined INST_PATH, do the installation.
  316. #  In this case, just copy the software and execute the application.
  317.  
  318. echo " "
  319. echo "Installing $MYAPP.  Please wait..."
  320. /bin/cp -r $CD_PATH $INST_PATH
  321.  
  322. cat > $INST_PATH/LaunchIt <<EOF
  323. #
  324. #   Set up the environment
  325. #
  326.  
  327.     setenv HOTMIXDIR "$HOTMIXDIR"
  328.     if ( \$?XUSERFILESEARCHPATH ) then
  329.     setenv XUSERFILESEARCHPATH "$INST_PATH/lib/Zmail:\$XUSERFILESEARCHPATH"
  330.     endif
  331.     setenv XAPPLRESDIR "$INST_PATH/lib"    # Just in case
  332.     setenv ZMLIB "$INST_PATH/lib"
  333.  
  334. #
  335. #   Change back to home dir and launch
  336. #
  337.  
  338.     cd $HOME
  339.     $INST_PATH/zmail -gui
  340. EOF
  341. chmod a=rx $INST_PATH/LaunchIt
  342.  
  343. echo " "
  344. echo "Done."
  345.  
  346. echo " "
  347. echo "To run the demo, move to the $INST_PATH directory"
  348. echo "and execute LaunchIt."
  349. echo " "
  350. echo " "
  351. echo "Do you want to run the demo now (y/n)?  \c"
  352. set ans=($<)
  353.  
  354. if ( $ans == 'y' ) then
  355.     $INST_PATH/LaunchIt
  356. else
  357.     echo "... Bye."
  358.     sleep 3
  359. endif
  360.  
  361. exit 0
  362.